import { ref } from "vue";
import service from "../index.js";

const accountApi = {
    //根据日期查询账单
    selectAll(pageNum,data){
        const params = {
            pageNum: pageNum,
            data: data
        }
        return service.get('/admin/account', {params});
    },
    //根据老人查询账单
    selectByEname(pageNum,ename){
        const params = {
            pageNum: pageNum,
            ename: ename
        }
        return service.get('/admin/account/elderly', {params});
    },
    //回显账单数据
    selectByAid(aid){
        const params = {
            aid: aid
        }
        return service.get('/admin/account/byaid',{params})
    },
    //修改老人的账单
    updata(account){
        return service.put('/admin/account',account)
    },
    //新增老人的账单
    insert(account){
        return service.post('/admin/account',account)
    },
    uploadExcel(data){
        const params = {
            data: data,
          };
        return service.get('/admin/file/downloadacc',{ params, responseType: 'blob'});
    },
    selecyInfoByUser(data){
        const params = {
            data: data,
          };
        return service.get('/user/account',{params})
    },
    allElderly(){
        const now = new Date();
        const year = now.getFullYear();
        const month = ('0' + (now.getMonth() + 1)).slice(-2);
        const day = ('0' + now.getDate()).slice(-2);
        const data = year + '-'+ month + '-' +day;
        const params = {
            data: data,
          };
        return service.get('/admin/account/allElderly',{params})
    },
    selectByAidByUser(aid){
        const params = {
            aid: aid
        }
        return service.get('/user/account/byaid',{params})
    },
    updateAccountElderly(aid){
        return service.put(`/user/account/${aid}`)
    }
    
}
export default accountApi;